<?php
require_once ('config.php');
require_once ('databasefunctions.php');
require_once ('displayfunctions.php');
validate_user();

switch ($_GET['action']) {
	case "save":
		if ($_GET['remark']) {
			$_SESSION['remark'][$_GET['remark_id']] = $_GET['remark'];
		}
		?>
		<script>
			window.opener.document.timesheet.remark<? echo $_GET['remark_id'] ?>.value = '<? echo $langmodify ?>';
			window.close();
		</script>
		<?
		break;
		
	case "clear":
		unset ($_SESSION['remark'][$_GET['remark_id']]);
		?>
		<script>
			window.opener.document.timesheet.remark<? echo $_GET['remark_id'] ?>.value = '<? echo $langadd ?>';
			window.close()
		</script>";
		<?
		break;
	
	default :
		$column = $_GET['remark_id'] + 1;
		echo "$langremark : $langclientincolumn $column" 
		?>
		<br>
		<form method="GET" action='timesheetremark.php'>
			<textarea cols="35" rows="4" name="remark"><?
			if ($_SESSION['remark'][$_GET['remark_id']]) {
				echo $_SESSION['remark'][$_GET['remark_id']];
			} ?></textarea>
			<br>
			<input type = "button" value = '<? echo $langclear ?>' onclick='clearremark()'>
			<input type = 'hidden' name = 'remark_id' value = '<? echo $_GET['remark_id'] ?>'>
			<input type = 'hidden' name = 'action' value = 'save'>
			<input type = 'submit' value = '<? echo $langadd ?>'>
		</form>
		
		<script>
		function clearremark() {
			this.location = 'timesheetremark.php?action=clear&remark_id=<? echo $_GET['remark_id'] ?>'
		}
		</script>
		<?
		break;
}
